package com.dongdong.service.impl;

import com.dongdong.mapper.TbAdminMapper;
import com.dongdong.model.TbAdmin;
import com.dongdong.model.TbAdminExample;
import com.dongdong.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AdminServiceImpl implements AdminService {

    @Autowired
    private TbAdminMapper adminMapper;

    @Override
    public TbAdmin getAdminByName(String username) {
        TbAdminExample example = new TbAdminExample();
        example.createCriteria().andUsernameEqualTo(username);
        List<TbAdmin> tbAdmins = adminMapper.selectByExample(example);
        if (tbAdmins != null && tbAdmins.size()>0){
            return tbAdmins.get(0);
        }
        return null;
    }
}
